package com.smartj.web.controller;


import com.smartj.web.common.exception.BizException;
import com.smartj.web.common.result.CommonMessage;
import com.smartj.web.common.result.annotation.ResultBody;
import com.smartj.web.vo.Person;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("main")
public class MainController {

    @GetMapping("/getPerson")
    @ResultBody
    public Person getPerson() {
        Person person = new Person();
        person.setAge(10);
        person.setName("张三");
        person.setMale(false);
        return person;
    }

    /**
     * @return
     */
    @GetMapping("/getPersonButException")
    @ResultBody
    public Person getPersonButException() {
        Person person = new Person();
        person.setAge(10);
        person.setName("张三");
        person.setMale(false);
        throw new BizException(CommonMessage.NOT_FOUND);
    }

    @GetMapping("getNullData")
    @ResultBody
    public String getNullData() {
        return null;
    }


    @GetMapping("getVoid")
    @ResultBody
    public void getVoid() {

    }
}
